package cn.com.freelibra.forum.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.com.freelibra.forum.web.view.AjaxObject;

@Controller
@RequestMapping("/api-test")
public class TestApi {
	
	@RequestMapping(value = "test")
	@ResponseBody
	public AjaxObject test(@ModelAttribute AjaxObject dataObj,HttpServletRequest request, HttpServletResponse response) {
		response.addHeader("Access-Control-Allow-Origin", "*");
		response.addHeader("Access-Control-Allow-Methods", "POST,OPTIONS");
		response.addHeader("Access-Control-Allow-Headers", "POWERED-BY-FANTONG");
		response.addHeader("Access-Control-Allow-Credentials", "true");
		response.addHeader("Access-Control-Max-Age", "1000");
		return dataObj;
	}
	
	@RequestMapping(value = "test-wen")
	@ResponseBody
	public AjaxObject test1(@RequestBody AjaxObject dataObj,HttpServletRequest request, HttpServletResponse response) {
		response.addHeader("Access-Control-Allow-Origin", "*");
		response.addHeader("Access-Control-Allow-Methods", "POST,OPTIONS");
		response.addHeader("Access-Control-Allow-Headers", "POWERED-BY-FANTONG");
		response.addHeader("Access-Control-Allow-Credentials", "true");
		response.addHeader("Access-Control-Max-Age", "1000");
		return dataObj;
	}

}
